package com.pluser.mq.engine;

import java.io.IOException;

import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.pluser.mq.vo.QueueInfo;
import com.pluser.mq.vo.QueueManagerInfo;

/**
 * 
 * Sender class
 * @author pluser
 * @version 1.0
 * @date 2014-05-03
 * @modifiedHis
 *
 * @description
 * Sender class that put message into queue
 */
public class Sender extends AbstractHandler {

	/**
	 * constructor
	 * @param qmInfo info of queue manager
	 * @param qInfo info of queue
	 * @throws MQException
	 */
	public Sender(QueueManagerInfo qmInfo, QueueInfo qInfo) 
			throws MQException {
		super(qmInfo, qInfo);
	}
	
	@Override
	public void putMsg(byte[] msgBytes, MQPutMessageOptions pmo) 
			throws IOException, MQException {
		
		MQMessage inMsg = new MQMessage();
		
		inMsg.write(msgBytes);
		getQueue().put(inMsg, pmo);
	}
	
}
